package com.tyk.bookstore.back.system.valid.validator;

import com.tyk.bookstore.back.common.core.valid.util.ValidUtil;
import com.tyk.bookstore.back.system.valid.annotation.AccountValid;
import com.tyk.bookstore.back.system.valid.constant.UserValidConstant;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class AccountConstraintValidator implements ConstraintValidator<AccountValid, String> {

	@Override
	public boolean isValid(String value, ConstraintValidatorContext context) {
		return value == null || ValidUtil.validString(value, UserValidConstant.ACCOUNT_MIN_LENGTH,
				UserValidConstant.ACCOUNT_MAX_LENGTH, UserValidConstant.ACCOUNT_PATTERN);
	}

}
